﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace Bussines
{
    public class clTIPUS
    {
        public string fTPS_KATEGORIA;
        public int fTPS_TIPUSKOD;
        public string fTPS_MEGNEVEZES;

        public clTIPUS (string iTPS_KATEGORIA , int iTPS_TIPUSKOD , string iTPS_MEGNEVEZES)
        {
            fTPS_KATEGORIA = iTPS_KATEGORIA;
            fTPS_TIPUSKOD = iTPS_TIPUSKOD;
            fTPS_MEGNEVEZES = iTPS_MEGNEVEZES;
        }
    }

    public class clTIPUS_LIST
    {
        private SqlConnection sc;

        public List<clTIPUS> lTIPUS = new List<clTIPUS>();

        public clTIPUS_LIST(TBLObj iBLObj, string iTPS_KATEGORIA)
        {
            TBLObj pBLObj = iBLObj;
            sc = iBLObj.sqlConnection;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = sc;

            cmd.CommandType = CommandType.Text;

            cmd.CommandText = "SELECT TPS_KATEGORIA, TPS_TIPUSKOD, TPS_MEGNEVEZES " +
                "FROM TIPUS " +
                "WHERE TPS_KATEGORIA = @TPS_KATEGORIA ";

            cmd.Parameters.Add(new SqlParameter("TPS_KATEGORIA", SqlDbType.VarChar ));

            cmd.Parameters["TPS_KATEGORIA"].Value = iTPS_KATEGORIA;            

            SqlDataReader rdr = cmd.ExecuteReader();
            while (rdr.Read())
            {
                clTIPUS t = new clTIPUS(rdr["TPS_KATEGORIA"].ToString(), (int)rdr["TPS_TIPUSKOD"], rdr["TPS_MEGNEVEZES"].ToString());
                lTIPUS.Add(t);
            }
            rdr.Close();
        }

    }
}
